//
//  QXBaseTableVC.swift
//  QXWeibo
//
//  Created by QinXin on 15/6/23.
//  Copyright © 2015年 labi3285_Lab. All rights reserved.
//

import UIKit

class QXBaseTableVC: UITableViewController, QXVisitLoginViewDelegate {
    
    
    var isLogon = sharedAccount != nil;
    
    var visitView: QXVisitLoginView?

    override func loadView() {
        
        isLogon ? super.loadView() : setupVisitView()
        
    }
    
    private func setupVisitView() {
        visitView = QXVisitLoginView ()
        view = visitView!
        
        visitView?.delegate = self
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "register")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
    }
    
    func register() {
    }
    
    func login() {
        
        let oauthVc = QXOAuthVC()
        let nav = UINavigationController(rootViewController: oauthVc)

        presentViewController(nav, animated: true, completion: nil);
    }
    
    func visitLoginViewDidClickLogin() {
        login()
    }
    
    func visitLoginViewDidClickRegister() {
        register()
    }    

}
